class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-10-16",
      revision: "a7f5a626135364abdc6d9d7b2b186673b2d80825"
  version "2021-10-16"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "406ad56ea73c6f6a0f3aa737aafb7f9c82ea0e729f9e6ebee30c9e2b8cef37b5"
    sha256 cellar: :any_skip_relocation, big_sur:       "a6d57a11f0630fdba67851fd89d2fb610473e13a245c5f4f437dcf3b9785c19e"
    sha256 cellar: :any_skip_relocation, catalina:      "15f7d716552391223a215dc40b0c40539c613a95028f914de0d19577ad30e883"
    sha256 cellar: :any_skip_relocation, mojave:        "0f02f68b510d9e27782b2d21a8ee0c0045158486b89bb2325a48491b5ca1befa"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "9ea3ac9b8e2ed1e7288b0e8100b69751e9ee94ff9bf3f8b663af5e4097c34700" # linuxbrew-core
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
